﻿using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class Data_Train : Data
    {
        #region[Train_Insert]
        public void Train_Insert(Train data)
        {
            using (SqlCommand cmd = new SqlCommand("sp_Train_Insert", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Train_No");
                cmd.Parameters.Add("@Train_Name");
                cmd.Parameters.Add("@Station_Name");
                cmd.Parameters.Add("@Route_Name");
                cmd.Parameters.Add("@AC_1");
                cmd.Parameters.Add("@AC_2");
                cmd.Parameters.Add("@AC_3");
                cmd.Parameters.Add("@Sleeper");
                cmd.Parameters.Add("@General");

                cmd.ExecuteNonQuery();
            }
        }
        #endregion

        #region[Train_Update]
        public void Train_Update(Train data)
        {
            using (SqlCommand cmd = new SqlCommand("sp_Train_Update_ByID", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Train_No");
                cmd.Parameters.Add("@Train_Name");
                cmd.Parameters.Add("@Station_Name");
                cmd.Parameters.Add("@Route_Name");
                cmd.Parameters.Add("@AC_1");
                cmd.Parameters.Add("@AC_2");
                cmd.Parameters.Add("@AC_3");
                cmd.Parameters.Add("@Sleeper");
                cmd.Parameters.Add("@General");

                cmd.ExecuteNonQuery();
            }
        }
        #endregion


        #region[Train_GetByAll]
        public DataTable Train_GetAll()
        {
            using (SqlCommand cmd = new SqlCommand("sp_Train_GetAll", GetConnection()))
            {
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);

                return dt;
            }
        }
        #endregion
    }
}
